<?php
/**
* @method: HomeController
* @author: PhuNguyen
* @description : main controller for project
* @created at : 2013-06-22
* @param : param
* @return : return
**/
class HomeController extends Controller
{

	// -----------------------------------------------------------
	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/

    public function actionIndex(){
    	$this->forward('home/index');
    }

    public function actionLogin(){
    	$this->layout = "blue_blank_layout";
		$model=new LoginForm;
		// collect user input data
		if(isset($_POST['LoginForm']))
		{
			$model->attributes=$_POST['LoginForm'];
			// validate user input and redirect to the previous page if valid
			if($model->validate() && $model->login())
				$this->redirect(Yii::app()->createUrl('/'));
		}
    	$this->render('login', array('model' => $model));
    }

    public function actionLogout(){
		Yii::app()->user->logout();
		$this->redirect(Yii::app()->createUrl('home/login'));
    }
}